﻿#if !LITE
using System;
using System.Collections.Generic;
using System.Text;

using Elegant.Ui;
using iPdf.Properties;

namespace iPdf
{
    class FormatGallery : Gallery
    {
        public PdfCreatorFormat SelectedFormat
        {
            get
            {
                GalleryItem selectedItem = (GalleryItem)this.SelectedItem;
                return (PdfCreatorFormat)selectedItem.Data;
            }
            set
            {
                foreach (GalleryItem item in this.Items)
                {
                    PdfCreatorFormat format = (PdfCreatorFormat) item.Data;
                    if (format == value)
                    {
                        this.SelectedItem = item;
                        this.EnsureItemVisible(item);
                        return;
                    }
                }
            }
        }

        public FormatGallery()
            : this(false)
        {
        }

        public FormatGallery(bool includeImageFormats)
        {
            this.MaximumItemsInRowCount = 3;
            this.MinimumItemsInRowCount = 3;
            this.ItemWidth = 78;
            this.ItemHeight = 62;
            this.ItemContentPadding = new System.Windows.Forms.Padding(6);
            this.ItemContentBackgroundColor = System.Drawing.Color.LightSkyBlue;
            this.InteractionMode = GalleryInteractionMode.Selection;
            this.InformativenessMinimumLevel = "Elegant.Ui.RibbonGroupGalleryInformativenessLevel:Expanded";
            this.LargeImages.Images.AddRange(new Elegant.Ui.ControlImage[] {
            new Elegant.Ui.ControlImage("Normal", global::iPdf.Properties.Resources.Format)});
            this.SmallImages.Images.AddRange(new Elegant.Ui.ControlImage[] {
            new Elegant.Ui.ControlImage("Normal", global::iPdf.Properties.Resources.Format16)});
            if (!Control.IsInDesignMode)
            {
                this.InitializeItems(includeImageFormats);
            }

            this.SelectedItem = this.Items[0];
        }

        private void InitializeItems(bool includeImageFormats)
        {
            this.Items.AddRange(
                new GalleryItem[]{
                    new GalleryItem(PdfCreatorFormat.PDF, Resources.PDF, null, Resources.StandardPdfFormat, null),
                    new GalleryItem(PdfCreatorFormat.PDF_A, Resources.PDF_A, null, Resources.PdfArchiveFormat, null),
                    new GalleryItem(PdfCreatorFormat.PDF_X, Resources.PDF_X, null, Resources.PdfExchangeFormat, null)
                });

            if (includeImageFormats)
            {
                this.Items.AddRange(
                new GalleryItem[]{
                    new GalleryItem(PdfCreatorFormat.JPEG, Resources.JPEG, null, Resources.JpegFormat, null),
                    new GalleryItem(PdfCreatorFormat.PNG, Resources.PNG, null, Resources.PngFormat, null),
                    new GalleryItem(PdfCreatorFormat.BMP, Resources.BMP, null, Resources.BitmapFormat, null),
                    new GalleryItem(PdfCreatorFormat.TIFF, Resources.TIFF, null, Resources.TiffFormat, null),
                    new GalleryItem(PdfCreatorFormat.ICO, Resources.ICO, null, Resources.IcoFormat, null),
                    new GalleryItem(PdfCreatorFormat.GIF, Resources.GIF, null, Resources.GifFormat, null),
                    new GalleryItem(PdfCreatorFormat.WMF, Resources.WMF, null, Resources.WmfFormat, null),
                    new GalleryItem(PdfCreatorFormat.EMF, Resources.EMF, null, Resources.EmfFormat, null),
                    new GalleryItem(PdfCreatorFormat.EXIF, Resources.EXIF, null, Resources.ExifFormat, null)
                });
            }
        }
    }
}

#endif